GUI Help > Special > getCanvasImage

getCanvasImage
getCanvasImage handle gadget, int imageId

Description:
Copies the contents of a canvas gadget to an image. The image must not already exist (use DELETE IMAGE first if it does).

Important: There *must* be a memblock command in your source code. The code does not have to be run, but its presence forces the compiler to include the memblocks plugin in your program. See the example source below

Return Value:


Parameters:
gadget Handle of a canvas gadget
imageId The number of the image you want the canvas contents to be copied to.
Remarks:
The user must be running in 32bit mode for this command to work. You can check the display depth using the SCREEN DEPTH function.

getImageCanvas is a fairly fast command - it takes around 16ms to copy a 200x200 canvas on a Pentium 4. For this reason it may be faster than using the native DBPro 2D commands.

You must have at least one memblock slot free for this command to work. You can have up to 255 memblocks, and as long as one is free the plugin will automatically use it and then delete it afterwards.

See Also:


Example:
(Note: You will need to include the GUI constants file for this example to work)

cv=createCanvas(0,0,200,200,0)

setDrawingColor cv,RGB(0,255,0),RGB(255,0,0),0

drawRect cv,0,0,200,200
getCanvasImage cv,1
paintGadget cv

do	
	getEvent
	
	paste image 1,300,100
loop

function neverRun()
	delete memblock 0
endfunction